﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Diagnostics;
using System.Windows.Forms;
using Contract;
using System.IO;
using System.Net;
using System.Net.Sockets;

namespace client
{
    public partial class QuitGroup : Form
    {
        string PCN;
        string GroupID;
        public QuitGroup(string pcn, string groupID)
        {
           PCN = pcn;
           GroupID = groupID;
           
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            NetTcpBinding binding = new NetTcpBinding();
            binding.TransferMode = TransferMode.Streamed;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.MaxReceivedMessageSize = 9223372036854775807;

            EndpointAddress address = new EndpointAddress("net.tcp://" + Dns.GetHostAddresses(Environment.MachineName)[2].ToString() + ":5000/DataUploader");
            ChannelFactory<IDataUploader> channel = new ChannelFactory<IDataUploader>(binding, address);
            IDataUploader Proxy = channel.CreateChannel();
            if (Proxy.quitGroup(PCN, GroupID) == true)
            {
                MessageBox.Show("U have quit the Group ID: " + GroupID);
            }
            else
            {
                MessageBox.Show("Since you are the Owner of Grou ID: " + GroupID, "your quit lead to the delete of this group.");
            }

                   
                   
        }
    }
}
